
//
//  AbsentClassCell.m
//  BOSS-SOOC
//
//  Created by apple on 16/9/6.
//  Copyright © 2016年 Gcx. All rights reserved.
//

#import "AbsentClassCell.h"
#import "AbsentClassModel.h"
#import "UIView+WHC_AutoLayout.h"

@implementation AbsentClassCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];

    if (self) {
        
        _titleLabel = [UILabel new];
        _timeLabel = [UILabel new];
        _contentLabel = [UILabel new];
        
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _titleLabel.font = NormalFont(42);
        _titleLabel.textColor = Color333333;
        [self.contentView addSubview:_titleLabel];

        _timeLabel.textAlignment = NSTextAlignmentRight;
        _timeLabel.font = NormalFont(36);
        _timeLabel.textColor = Color999999;
        [self.contentView addSubview:_timeLabel];
        
        
        _contentLabel.textAlignment = NSTextAlignmentLeft;
        _contentLabel.textColor = color666666;
        _contentLabel.font = NormalFont(39);
        [self.contentView addSubview:_contentLabel];

        
        _titleLabel.whc_LeftSpace(ScaleSize(42))
                    .whc_TopSpace(ScaleSize(63))
                    .whc_Size(CGSizeMake(200, 20));
        
        _timeLabel.whc_TopSpace(ScaleSize(63))
                    .whc_LeftSpaceToView(0,_titleLabel)
                    .whc_Height(20)
                    .whc_RightSpace(ScaleSize(42));
        
        _contentLabel.whc_TopSpaceToView(ScaleSize(33),_titleLabel)
                    .whc_LeftSpace(ScaleSize(42))
                    .whc_RightSpace(ScaleSize(42))
                    .whc_heightAuto();
    }
    return self;
}

- (void)setMyModel:(AbsentClassModel *)myModel{

    _myModel = myModel;
    
    _timeLabel.text = [self since1970String:myModel.input_time];
    _contentLabel.text = myModel.ktzt;
}

//时间戳转换
- (NSString *)since1970String:(NSString *)data
{
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    [formatter setDateFormat:@"YYYY-MM-dd"];
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:[data intValue]];
    NSString * nowtimeStr = [formatter stringFromDate:date];
    
    return nowtimeStr;
}

@end
